% read_tai.m - read a .tai file

function [tai] = read_tai(file_name)
    
fid=fopen(file_name,'r');
dum=fgetl(fid); % '...Scaling'
if strcmp(dum,'UofI new scaling ')
    dum=fgetl(fid); % BRIK size
    dum=fgetl(fid); % scaling
end
if strcmp(dum,'UofI new scaling')
    dum=fgetl(fid); % BRIK size
    dum=fgetl(fid); % scaling
end
if strcmp(dum,'U of I 2008 scaling ')
    dum=fgetl(fid); % BRIK size
    dum=fgetl(fid); % scaling
end
if strcmp(dum,'U of I 2008 scaling')
    dum=fgetl(fid); % BRIK size
    dum=fgetl(fid); % scaling
end
dum=fgetl(fid);
tai.scale=sscanf(dum,'%g',3)';

for i=1:11
    dum=fgetl(fid);
	dum=fgetl(fid);
	tai.xyz(i,:)=sscanf(dum,'%i',3)';
end

tai.xyz=tai.xyz+1;  % afni voxels go from 0 to n-1, we need 1 to n




